import numpy as np

# 1.绝对值函数
arr_v = np.array( [-10, 0, 10] )
abs_v = np.abs(arr_v)
print( '原数组是：' , arr_v ) #  [-10 0 10]
print( '绝对值是：' , abs_v ) # [10 0 10]
# 2.三角函数
theta = np.arange(3) * np.pi / 2
sin_v = np.sin(theta)
cos_v = np.cos(theta)
tan_v = np.tan(theta)
print( '原数组是：' , theta ) #  [0.         1.57079633 3.14159265]
print( '正弦值是：' , sin_v ) # [0.0000000e+00 1.0000000e+00 1.2246468e-16]
print( '余弦值是：' , cos_v ) # [ 1.000000e+00  6.123234e-17 -1.000000e+00]
print( '正切值是：' , tan_v ) # [ 0.00000000e+00  1.63312394e+16 -1.22464680e-16]

# 3 指数函数
x = np.arange(1,4)
print( 'x =' , x ) # [1 2 3]
print( 'e^x =' , np.exp(x) ) # [ 2.71828183  7.3890561  20.08553692]
print( '2^x =' , 2**x ) # [2 4 8]
print( '10^x = ' , 10**x ) # [  10  100 1000]

# 4 对数函数
x = np.array( [1,10,100,1000] )
print( 'x =' , x ) #  [   1   10  100 1000]
print( 'ln(x) =' , np.log(x) ) #[0.         2.30258509 4.60517019 6.90775528]
print( 'log2(x) =' , np.log(x) / np.log(2) ) # [0.         3.32192809 6.64385619 9.96578428]
print( 'log10(x) =' , np.log(x) / np.log(10) ) # [0. 1. 2. 3.]